$(function(argument) {
	var uid = window.localStorage.getItem("user_id");
	var poid = window.sessionStorage.getItem("poid");
	var shopN = window.sessionStorage.getItem("shopN");
	console.log(shopN);

	function getTime(a) {
		var a = arguments[0];
		var date = new Date(Number(a) * 1000);
		var Y = date.getFullYear() + '-';
		M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
		D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
		h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
		m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
		s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
		// var time_new_xu = Y + M + D + h + m + s;
		var time_new_xu = Y + M + D;
		return time_new_xu;
	}
	// 获取去地址
	$.ajax({
		url: 'http://www.teaweilai.com/app/Admin/Order/AddressOrder',
		type: 'POST',
		dataType: 'json',
		data: {
			uid: uid,
			parent_order_id: poid
		},
		success: function(data) {
			console.log(data);
			var strA =
				'<div class="row user">' +
				'<div class="col-xs-6 userName">收货人 :<span>' + data.sing.consignee + '</span></div>' +
				'<div class="col-xs-6"><span class="phoneNumber">' + data.sing.mobile + '</span></div>' +
				'<div class="col-xs-12">收货地址：<span class="userAdress">' + data.sing.address + '</span></div>' +
				'</div>';
			$(".person").html(strA);
			var strP =
				'<div class="row">' + '<div class="col-xs-5 ar">' + '物流金额' + '</div>' + '<div class="col-xs-7">' + '<span class="postage">' + data.sing.shipping_fee + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '卡券总额' + '</div>' + '<div class="col-xs-7">' + '<span class="actual_payment ">' + data.sing.c_money + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '支付总额' + '</div>' + '<div class="col-xs-7">' + '<span class="actual_payment ">' + data.sing.order_amount + '</span>' + '</div>' + '</div>';
			$(".pay").html(strP);
			var strI;
			if (data.sing.order_status == 5 && data.sing.pay_status == 2 && data.sing.shipping_status == 2) {
				strI =
					'<div class="row">' + '<div class="col-xs-5 ar">' + '订单编号' + '</div>' + '<div class="col-xs-7">' + '<span class="allPay">' + data.sing.order_sn + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '创建时间' + '</div>' + '<div class="col-xs-7">' + '<span class="postage">' + getTime(data.sing.add_time) + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '支付时间' + '</div>' + '<div class="col-xs-7">' + '<span class="actual_payment ">' + getTime(data.sing.pay_time) + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '发货时间' + '</div>' + '<div class="col-xs-7">' + '<span class="actual_payment ">' + getTime(data.sing.shipping_time) + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '收货时间' + '</div>' + '<div class="col-xs-7">' + '<span class="actual_payment ">' + getTime(data.sing.confirm_time) + '</span>' + '</div>' + '</div>';
			} else {
				strI =
					'<div class="row">' + '<div class="col-xs-5 ar">' + '订单编号' + '</div>' + '<div class="col-xs-7">' + '<span class="allPay">' + data.sing.order_sn + '</span>' + '</div>' + '<div class="col-xs-5 ar">' + '创建时间' + '</div>' + '<div class="col-xs-7">' + '<span class="postage">' + getTime(data.sing.add_time) + '</span>' + '</div>' + '</div>';
			}

			$(".informational").html(strI);
			$(".shopTitle a").html(shopN);
		}
	})

	// 获取商品
	$.ajax({
		url: 'http://www.teaweilai.com/app/Admin/Order/DetailsOrder',
		type: 'POST',
		dataType: 'json',
		data: {
			uid: uid,
			parent_order_id: poid
		},
		success: function(data) {
			// console.log(data);
			var strG = template("goodsL", {
				goodsOne: data
			});
			$(".goodsList").html(strG);
		}
	})



	// 点击确定跳转到订单列表
	$(".sure").click(function() {
		window.sessionStorage.removeItem(poid);
		window.location.href = "order_list.html";
	})

})